import axios from "@/api/config"

export async function getExamTasksList(data) { //获取考试列表
    const url = `/exam/exam_tasks?page=${data.page}&limit=${data.limit}&section=${data.section}&name=${data.name}`;
    let res = await axios.get(url);
    return res.data;
}
export async function addExamTasks(data) { //考试新增
    const url = '/exam/exam_task';
    const res = await axios.post(url,data);
    return res.data;
}
export async function getExamTasksDetail(data) { //获取普通的考试信息
    const url = '/exam/exam_task/'+data;
    const res = await axios.get(url);
    return res.data;
}
export async function getExamTasksStu(data) { //获取添加的考生数量
    const url = '/exam/exam_task/added_employees/'+data;
    const res = await axios.get(url);
    return res.data;
}
export async function updateExamTasks(data) { //更新普通考试信息
    const url = '/exam/exam_task';
    const res = await axios.put(url,data);
    return res.data;
}
export async function updateExamTasksStu(data) { //更新选择的考生信息
    const url = '/exam/exam_task/employees';
    const res = await axios.put(url,data);
    return res.data;
}
export async function deleExamTasks(data) { //删除考试
    const url = '/exam/exam_task/'+data;
    const res = await axios.delete(url);
    return res.data;
}

export async function getExamTasksResult(data) { //查询考试情况
    const url = `/exam/exam_task/employee_tasks?page=${data.page}&limit=${data.limit}&section=${data.section}&name=${data.name}&shop=${data.shop}&group=${data.group}&workerID=${data.workerID}&examID=${data.examID}`;
    let res = await axios.get(url);
    return res.data;
}

export async function getExamResult(data) { //考试结果
    const url = `/exam/employee_exam_result?examId=${data.examId}&workerId=${data.workerId}`
    const res = await axios.get(url);
    return res.data;
}

export async function getExamImg (url) { //考试结果
    console.log(url)
    const res = await axios.get(url,{
        responseType: "arraybuffer",
    });
    return res.data;
}